#include "SCI_HAL_GB.h"
#include "TPM_HAL_GB.h"
#include "Services.h"
#include "LCD_Handler.h"

#define COMM_SENSOR_SCI_CHAN   1

#define COMM_REQUEST_PACKET1    0xF0

#define COMM_COMMAND_CALIBRATE  0x0F

#define COMM_ANSWER_HELLO_OK			0xF5
#define COMM_ANSWER_HELLO_ACCEL_FAIL	0xFA

#define COMM_COMMAND_HELLO  	0xAA

#define COMM_SENSOR_PACKET_SIZE 6

#define COMM_TIMEOUT          250

#define COMM_TX_SMAC_PACKET_SIZE    11

#define COMM_RX_SMAC_PACKET_SIZE    15

#define PLANE_OFF   0x00
#define PLANE_ON    0x01

#define COMM_REQ_RESET_SURFACE_LIMITS   0x3F00

#define COMM_REQ_SET_AILERON_MAX_LEFT	1<<13
#define COMM_REQ_SET_AILERON_MAX_RIGHT	1<<12
#define COMM_REQ_SET_RUDDER_MAX_LEFT	1<<11
#define COMM_REQ_SET_RUDDER_MAX_RIGHT	1<<10
#define COMM_REQ_SET_ELEVATOR_MAX_UP	1<<9
#define COMM_REQ_SET_ELEVATOR_MAX_DOWN	1<<8

#define COMM_REQ_SET_GPS_HOME			1<<7
#define COMM_REQ_SET_AILERON_ZERO		1<<6
#define COMM_REQ_SET_RUDDER_ZERO		1<<5
#define COMM_REQ_SET_ELEVATOR_ZERO		1<<4

#define COMM_REQ_SET_ACCEL_ZERO			1<<3
#define COMM_REQ_TURN_ON_OFF_ULTRASONIC	1<<2
#define COMM_REQ_TURN_ON_OFF_PLANE		1<<1
#define COMM_REQ_TURN_ON_MOTOR			1<<0

#define AUTO_PILOT_DEFAULT_SPEED	45
#define AUTO_PILOT_DEFAULT_ELEVATOR	128
#define AUTO_PILOT_DEFAULT_RUDDER	128
#define AUTO_PILOT_DEFAULT_AILERON	128

uint8 u8Comm_RequestSCIPacket (void);

void vfnComm_ConfigureSCI (void);

void vfnComm_SendSCICommand (uint8 u8command);

void vfnComm_ReadSCIPacket (void);

void vfnComm_BuildSMACPacket (void);

void vfn_CommSayHelloSensorManager(void);

void vfnComm_PutRequestOnSmacPacket(uint16 value);

void vfnComm_ReadSMACPacket (void);

void vnfServ_ChangeSchedulerPeriod(void);




